package com.example.adminframework.controller;

import com.example.adminframework.common.redis.Redis;
import com.example.adminframework.response.ResultContent;
import com.example.adminframework.util.AesUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api("测试模块")
@RestController("test")
public class TestController {

    @Autowired
    private Redis redis;

    @RequestMapping(method = RequestMethod.POST)
    public ResultContent test(){
        boolean user = redis.hasKey("user");
        return ResultContent.success(user);
    }



    @PostMapping("/aes/test")
    public ResultContent test1(){
        String name = "admin@jiraiya";
        try {
            name = AesUtil.encryptByKeyAndIv(name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResultContent.success(name);
    }
}
